
;(function(window, document){
	var Queue = function(pIntSize){
		this._maxSize = pIntSize;
		this._datas = [];
		this._front = 0;
		this._end = -1;
		this._length = 0;
	};
	Queue.prototype = {
		constructor: Queue,
		enque: function(pData){
			if( this.isFull() ) throw new Error('队列已满');
			if( this._end == this._maxSize - 1) this._end = -1;
			this._datas[++this._end] = pData;
			this._length ++;
		},
		deque: function(){
			if( this.isEmpty() ) throw new Error('队列已空');
			var value = this._datas[this._front++];
			if( this._front == this._maxSize ) this._front = 0;
			this._length --;
			return value;
		},
		isEmpty: function(){
			return this._length == 0;
		},
		isFull: function(){
			return this._length == this._maxSize;
		},
		peek: function(){
			return this._datas[this._front];
		},
		getSize: function(){
			return this._length;
		},
		toString: function(){
			return '['+this._datas.join(', ')+']';
		}
	};

	window.Queue = Queue;
})(window, document);